#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int narcissistic(int number);
void PrintN(int m, int n);

int main() {
	int m, n;

	scanf("%d %d", &m, &n);
	if (narcissistic(m))
		printf("%d is a narcissistic number\n", m);
	PrintN(m, n);
	if (narcissistic(n))
		printf("%d is a narcissistic number\n", n);

	return 0;
}
int narcissistic(int number) {
	int b = number;
	int tmp = number;
	int N = 0;
	int i;
	int j;
	int sum = 0;
	while (tmp) {
		tmp /= 10;
		N++;
	}
	j = N;
	tmp = 0;
	int sum1 = 1;
	while (number > 0) {
		tmp = number % 10;
		while (j--) {
			sum1 = sum1 * tmp;
		}

		sum += sum1;
		sum1 = 1;
		j = N;
		number /= 10;
	}
	if (sum == b)
		return 1;
	else
		return 0;
}

void PrintN(int m, int n) {
	int i = 0;
	for (i = m + 1; i < n; i++) {
		if (narcissistic(i))
			printf("%d\n", i);
	}
}